﻿using ERP.ErrorCode;
using ERP.Server.API.Applocation.Command;
using ERP.Server.API.DTOs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ERP.Server.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagemnetController : ControllerBase
    {
        IMediator mediator;
        ILogger<ManagemnetController> logger;
        public ManagemnetController(IMediator mediator, ILogger<ManagemnetController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        [HttpGet]
        public Task<APIResult<List<OrderQueryDto>>> ShowOrder()
        {
            OrderQueryCommand command =new OrderQueryCommand();
            return mediator.Send(command);
        }

        [HttpPost]
        public async Task<APIResult<int>> AddOrder([FromBody]OrderCreateCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
